<template>
  <view>
    <view class="photo">
      <image mode="widthFix" :src="brand_logo"></image>
    </view>
    <!-- 新api用 -->
    <!-- <button class="login_btn" v-if="!isAndroid" @click="getUserProfile">
      微信用户登录
    </button> -->
    <!-- <button
      class="login_btn"
      open-type="getUserInfo"
      @getuserinfo="getUserInfo"
    >
      微信用户登录
    </button> -->
    <!-- {{ isAndroid }} -->
    <view class="btn_box">
      <button class="photo_login_btn" :class="{ isAndroid: isAndroid }" open-type="getPhoneNumber"
        @getphonenumber="decryptPhoneNumber">
        手机号一键登录
      </button>
      <button class="photo_login_btn login_btn2" :class="{ isAndroid: isAndroid }" v-if="!checkedVal || !canLogin"
        @click.stop="isReadRuls">
        手机号一键登录
      </button>
    </view>
    <view class="radio_box">
      <u-checkbox-group>
        <u-checkbox activeColor="#de4141" @change="change"></u-checkbox>
      </u-checkbox-group>
      <view>
        我已阅读、理解并同意此<text class="policy" @click="openRules">《隐私政策》</text>。</view>
    </view>
    <RulesCompany ref="rule"></RulesCompany>
  </view>
</template>

<script>
import { mapState, mapMutations } from 'vuex'
import { UserLogin } from '@/mixins/UserLogin'
export default {
  mixins: [UserLogin], // 混入
  name: 'UserLogin',
  data() {
    return {}
  },
  created() {
    this.getCode()
  },
  computed: {
    ...mapState(['brandInfo', 'isAndroid']),
    brand_logo () {
      let { brand } = this.brandInfo
      return `https://www.kamlung.net/images/qrlogo/wx-${brand}.png`
    }
  },
  methods: {
    ...mapMutations(['saveLoginInfo']),
  },
}
</script>

<style lang="scss">
.photo {
  width: 190rpx;
  height: 190rpx;
  border-radius: 50%;
  border: 2rpx solid rgba(0, 0, 0, 0.05);
  background-color: #fff;
  margin: 220rpx auto 100rpx auto;
  display: flex;
  justify-content: center;
  align-items: center;

  image {
    width: 160rpx;
    height: 160rpx;
  }
}

.login_btn {
  // margin-top: 60rpx;
  margin-bottom: 60rpx;
  border-radius: 200rpx;
  width: 80%;
  font-size: 34rpx;
  background: #dd444c;
  color: #fff;
}

.photo_login_btn {
  margin-bottom: 60rpx;
  border-radius: 200rpx;
  width: 80%;
  font-size: 34rpx;
  // background: #fff;
  background: #dd444c;
  color: #fff;

  // color: #000;
  &::after {
    border: 2rpx solid rgba(0, 0, 0, 0.2);
    border-radius: 200rpx;
  }
}

.isAndroid {
  color: #fff;
  background: #dd444c !important;
}

.btn_box {
  position: relative;

  .login_btn2 {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
  }
}

.radio_box {
  display: flex;
  justify-content: center;
}

.policy {
  color: #dd444c;
}
</style>
